Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an AllocatedNum addition constraint #39

Merged
merged 2 commits into from
Oct 22, 2023
Merged

Add an AllocatedNum addition constraint #39

merged 2 commits into from
Oct 22, 2023

Conversation

varunthakore
Copy link
Contributor

@varunthakore varunthakore commented Oct 20, 2023

This pull request is corresponding to issue #33 created by @huitseeker. Added AllocatedNum addition constraint and corresponding test.

Copy link
Contributor

@huitseeker huitseeker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot! I think we can do a bit better on testing, but this is looking good.

@@ -539,6 +571,21 @@ mod test {
assert!(cs.get("num") == Fr::ONE);
}

#[test]
fn test_num_addition() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be great to see some negative testing here.
Another useful tool would be to exemplify the modular nature of the addition, e.g. by using something close to the field modulus as one of the operands.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated the test.

Comment on lines +588 to +592
assert!(cs.is_satisfied());
assert!(cs.get("sum num") == Fr::ZERO);
assert!(c.value.unwrap() == Fr::ZERO);
cs.set("sum num", Fr::ONE);
assert!(!cs.is_satisfied());
Copy link
Contributor Author

@varunthakore varunthakore Oct 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@huitseeker By negative testing, do you mean to add tests such that the constraint system is not satisfied ? I am checking for this on lines 591-592.

Copy link
Contributor

@huitseeker huitseeker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, TYSVM!

@huitseeker huitseeker added this pull request to the merge queue Oct 22, 2023
Merged via the queue into lurk-lang:main with commit 029eaad Oct 22, 2023
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants